package com.client.net;


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;

/**
 * 上传文件
 */
public class FormFile {
	/* 上传文件的数据 */ 
	private byte[] data;
	private InputStream inStream;
	private File file;
	private File media;
	private String id;
	/* 标题 */
	private String title;
	/* 描述 */
	private String description;
	/* URL地址 */
	private String urlPath;
	/* 事件关联Id */
	private String eventId;
	/* 文件名称 */
	private String fileName;
	/*
	 * 文件类型标识 1：图片文件 2：视频文件 3：其它文件
	 */
	private String fileType;
	/* 请求参数名称 */
	private String parameterName;
	/* 内容类型 */
	private String contentType = "application/octet-stream";

	public FormFile(String filname, byte[] data, String parameterName,
			String contentType) {
		this.data = data;
		this.fileName = filname;
		this.parameterName = parameterName;
		if (contentType != null)
			this.contentType = contentType;
	}

	public FormFile(String filname, File file, String parameterName,
			String contentType) {
		this.fileName = filname;
		this.parameterName = parameterName;
		this.file = file;
		try {
			this.inStream = new FileInputStream(file);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		if (contentType != null)
			this.contentType = contentType;
	}
	public FormFile() {
	}
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	public File getMedia() {
		return media;
	}

	public void setMedia(File media) {
		this.media = media;
	}

	public String getFileType() {
		return fileType;
	}

	public void setFileType(String fileType) {
		this.fileType = fileType;
	}
	public String getUrlPath() {
		return urlPath;
	}

	public void setUrlPath(String urlPath) {
		this.urlPath = urlPath;
	}

	public File getFile() {
		return file;
	}

	public InputStream getInStream() {
		return inStream;
	}

	public byte[] getData() {
		return data;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getEventId() {
		return eventId;
	}

	public void setEventId(String eventId) {
		this.eventId = eventId;
	}

	public String getFilename() {
		return fileName;
	}

	public void setFilename(String fileName) {
		this.fileName = fileName;
	}

	public String getParameterName() {
		return parameterName;
	}

	public void setParameterName(String parameterName) {
		this.parameterName = parameterName;
	}

	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	public HashMap<String, String> mMediaBaseToMap() {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("eventId", this.eventId);
		map.put("title", this.title);
		map.put("description", this.description);
		map.put("fileType", this.fileType);
		return map;
	}
}